package dowork;

import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.sutuijingling.a.e;
import com.sutuijingling.utils.c;
import org.apache.http.HttpStatus;

public class DSSettingViewer extends e {
    public DSSettingViewer(UiDevice uiDevice) {
        this.device = uiDevice;
    }

    public void backHome() throws UiObjectNotFoundException {
        doEnsureHomeLauncher();
        this.device.pressBack();
        this.device.pressBack();
        c.c();
        this.device.pressHome();
        c.c();
        doEnsureHomeLauncher();
        this.device.pressBack();
        c.c();
        this.device.pressBack();
        c.c();
    }

    public void modifyInputMethod() throws com.sutuijingling.result.c, UiObjectNotFoundException {
        backHome();
        this.device.pressMenu();
        UiObject uiObject = new UiObject(new UiSelector().text("设置"));
        if (!uiObject.exists()) {
            uiObject = new UiObject(new UiSelector().text("系统设置"));
        }
        ensureExist(uiObject, "点了 Menu 之后怎么找不到系统系统设置???");
        c.d(uiObject);
        uiObject = findText("语言和输入法", 2);
        if (!uiObject.exists()) {
            uiObject = findScroll().getChildByText(new UiSelector(), "语言和输入法", true);
        }
        ensureExist(uiObject, "找不到 语言和 输入法这个 entry");
        c.c(uiObject);
        c.a(2000);
        uiObject = findText("默认", 2);
        if (uiObject.exists()) {
            c.c(uiObject);
            c.a(1000);
            String str = "UTF7 IME for UI Testing";
            uiObject = findText(str, 2);
            if (uiObject.exists()) {
                c.c(uiObject);
                pressBack(3);
                return;
            }
            this.device.pressBack();
            uiObject = findText(str, 2);
            ensureExist(uiObject, " back to default page but no utf7,might not install");
            c.c(uiObject);
            c.c();
            uiObject = findText("确定 ", 2);
            if (!uiObject.exists()) {
                System.out.println(" no direct text confirm...");
                uiObject = new UiObject(new UiSelector().textContains("确定"));
                debugUiObject(uiObject);
            }
            c.c(uiObject);
            c.c();
            c.c(findText("默认", 2));
            c.a(1000);
            uiObject = findText(str, 2);
            c.a(1000);
            c.c(uiObject);
            pressBack(3);
            return;
        }
        throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "No default ....改不了默认输入法??");
    }

    public void settingByDesktopLogo() {
    }

    public void settingByMenu() {
    }

    public void setupQQBrowser() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        backHome();
        c.a(1000);
        UiObject findText = findText("QQ浏览器", 2);
        ensureExist(findText, " QQ 浏览器图标找不到");
        c.d(findText);
        c.a(500);
        findText = findText("拒绝", 1);
        if (findText.exists()) {
            c.c(findText);
        }
        this.device.pressMenu();
        c.a(1000);
        findText = findText("设置", 2);
        c.d(findText);
        ensureExist(findText, "QQ 浏览器里面怎么没有设置按钮了???");
        c.d(findText("高级", 2));
        ensureExist(findScroll().getChildByText(new UiSelector(), "浏览器标识", true), "QQ 浏览器里面怎么没有 浏览器标识");
        findText = findText("桌面版", 2);
        ensureExist(findText, "桌面版按钮怎么找不到了...");
        c.c(findText);
        c.a(1000);
    }
}
